package chapter13.section8;
//程序13-8实例化CachedRowSet对象以及访问数据库

import javax.sql.rowset.CachedRowSet;
import javax.sql.rowset.RowSetFactory;
import javax.sql.rowset.RowSetProvider;
import java.sql.SQLException;

public class CachedRowsetDemo {
    public static void main(String[] args) throws SQLException {
        RowSetFactory aFactory = RowSetProvider.newFactory();
        CachedRowSet crs = aFactory.createCachedRowSet();
        crs.setUrl("jdbc:mysql://localhost:3306/bank");
        crs.setUsername("root");
        crs.setPassword("123456");
        crs.setCommand("select * from tb_account");
        crs.execute();
        while (crs.next()) {
            System.out.println(crs.getString("name"));
        }
    }
}